from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
from frontend.views import TopHitsView, TopVotesView
#from django.conf.urls.i18n import i18n_patterns # to be released in django 1.4
import settings

admin.autodiscover()

urlpatterns = patterns('',    
    url(r'^admin/', include(admin.site.urls)),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    # globalresource ratings
    url(r'^i18n/', include('django.conf.urls.i18n')),    
    (r'^ratings/', include('ratings.urls')),
    url(r'^logout/$',
        'django.contrib.auth.views.logout',
        name='auth_logout'),
    url(r'^add_custom/$',
        'frontend.views.add_custom',
        name='add_custom_resource_url'),
    url(r'^random/',
        'frontend.views.get_random_resource',
        name='get_random_resource_url'),
    url(r'^ajax/hit/$', 'hitcount.views.update_hit_count_ajax',
        name='hitcount_update_ajax'),
    url(r'^top/views/',
        TopHitsView.as_view(),
        name='top_viewed'),
    url(r'^top/votes/',
        TopVotesView.as_view(),
        name='top_voted'),
    url(r'^$', 'frontend.views.index', name='index'),
    url(r'^resource/tag/(?P<pk>[^/]+)/$', 'frontend.views.tag_details', name="tag_details"),
    url(r'^resource/(?P<object_id>\d+)/', 'frontend.views.resource_details', name="resource_details"),
    # Curricular
    url(r'^activity/(?P<object_id>\d+)/', 'frontend.views.activity_details', name="activity_details"),
    url(r'^curricular/(?P<object_id>\d+)/', 'frontend.views.get_curricular_grade', name="curricular_grade"),
    )

if settings.DEBUG:
    urlpatterns += patterns('',
    # CONTENT MEDIA
    url(r'^media/(.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT}),
    )